import JSEncrypt from 'jsencrypt'

// 公钥
const publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCHFHbFrMcsq5+iD6fUoRD3mZV9fyQqk0v7PvAa\n" +
    "euKbIxZrwi5oikYV9qd6QdWlGQUVcJf1ulXFHpxJzGPEAUbbXtH+XRUEWuHQ0wMfxT9WRhroKeqb\n" +
    "6fKEVpyfSyC8ffuBYqtX4b7NHZxouiE6ncFp6Jw47aoFEr5BpUtj1434XQIDAQAB";
// 私钥
const privateKey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAIcUdsWsxyyrn6IPp9ShEPeZlX1/\n" +
    "JCqTS/s+8Bp64psjFmvCLmiKRhX2p3pB1aUZBRVwl/W6VcUenEnMY8QBRtte0f5dFQRa4dDTAx/F\n" +
    "P1ZGGugp6pvp8oRWnJ9LILx9+4Fiq1fhvs0dnGi6ITqdwWnonDjtqgUSvkGlS2PXjfhdAgMBAAEC\n" +
    "gYBYGtblVC6NSlvSnpd/LpcciEZjFpyGUJDMjV6aRvCq85XaL0uJ0DaqeLkAGxS4nLseItRa6HCt\n" +
    "I6wYzoF8BMErvS8AAEhWL2ahB3rgDJi3ya4B13MKlKkzi5hJi9fpm+TE45LbryIe9LSmeliQRzbM\n" +
    "mpLisgN9NJMJy7DSsIc1AQJBAMlwzRLjmCIy97x8R5UbP0YUfMkRVucxnoCQH0LvrgNQEj2nP4y5\n" +
    "4nSwZFCBvgNWhXf+CosHrgIlZyI4CjEt5OECQQCrqnD0q4hrJvtnThvaeL8CYstoMp+NXHB5PAJJ\n" +
    "/RCEPNO+VRrY9H6gtSPiVAwZBARHzQS7vECqhXu9Z0afBYb9AkEAncjzeSY41iDiGAuo7kxnZXdK\n" +
    "vxwL3A/rvXwmYIHo5cNkZlKI3qwDi69XBBB8S5UL+o9MptYfIKM3g4Aty5PNQQJBAJ36xOjl0y2J\n" +
    "OmPfphJwfJgdg0PpEpxtLbTkXNbqZYDM2bCXcZWnq8EJ8nQfFOMQpz/MlUaQAJLtNOshWASQeaEC\n" +
    "QQCzN4tIK+gDYyKVD4hhl9JPZ/amtkjagM0BsJIEy3XH9t6jTh/eIbj8QSp4LEdQv9NosDCBpCGE\n" +
    "ZbmPyzFmSUPJ";



// 私钥
// 加密
export function encrypt(txt:any) {
    const encryptor = new JSEncrypt() // 创建加密对象实例
    encryptor.setPublicKey(publicKey) // 设置公钥
    return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt:any) {
    const decryptor = new JSEncrypt() // 创建解密对象实例
    decryptor.setPrivateKey(privateKey) // 设置私钥
    return decryptor.decrypt(txt) // 对数据进行解密
}
